﻿namespace 
    ``Concerning the assertion syntax``

open FSpec
open FSpec.Operators 

module ``Numbers``=   

    //Operators 
    let ``it fail the equals operator``()=
        capture (fun()->
            1 &= 2
        )

    let ``it fail the isGreaterThan operator``()=
        capture (fun()->
            1L &> 2L
        )

    let ``it fail the isLessThan operator``()=
        capture (fun()->
            1I &< 0I
        )
    
    let ``it fail the isGreaterThanOrEqualTo operator``()=
        capture (fun()->
            1y &>= 2y
        )
    
    
    let ``it fail the isLessThanOrEqualTo operator``()=
        capture(fun()-> 
            1.0 &<= 0.99999
        )

    let ``it fail the isNotEqualTo operator``()=
        capture(fun()->
            1u &<> 1u
        )
    
    //Ranges
    let ``it fail should.beBetween Inclusive``()=
        capture(fun()->

            81<m/s> |> should.beBetween 1<m/s> And 10<m/s> Inclusive

        ).Description
        |> should.equal (format
                            Resources.TheValueShouldBeWithin_0_And_1_Inclusive 
                            [1<m/s>;10<m/s>])
    
    let ``it fail should.beBetween Exclusive - over upper boundary``()=
        capture(fun()->

            11 |> should.beBetween 0 And 10 Exclusive

        ).Description 
        |> should.equal (format
                            Resources.TheValueShouldBeWithin_0_And_1_Exclusive 
                            [0;10])

    let ``it fail should.beBetween Exclusive - on upper boundary``()=
        capture(fun()->

            10 |> should.beBetween 0 And 10 Exclusive

        ).Description 
        |> should.equal (format
                            Resources.TheValueShouldBeWithin_0_And_1_Exclusive
                            [0;10])

    let ``it fail should.beBetween Exclusive - under lower boundary``()=
        capture(fun()->

            -1 |> should.beBetween 0 And 10 Exclusive

        ).Description 
        |> should.equal (format
                            Resources.TheValueShouldBeWithin_0_And_1_Exclusive 
                            [0;10])

    let ``it fail should.beBetween Exclusive - on lower boundary``()=
        capture(fun()->
        
            0ul |> should.beBetween 0ul And 10ul Exclusive

        ).Description
        |> should.equal (format 
                            Resources.TheValueShouldBeWithin_0_And_1_Exclusive 
                            [0ul;10ul])

    let ``it fail shouldNot.beBetween - Inclusive``() =
        capture(fun()->
         
            1.0f |> shouldNot.beBetween 0.99999f And 1.000001f Inclusive

        ).Description 
        |> should.equal (format 
                            Resources.TheValueShouldNoBeWithin_0_And_1_Inclusive
                            [0.99999f;1.000001f])

    let ``it fail shouldNot.beBetween - exclusive``() =
        capture(fun()-> 
        
            1.0f |> shouldNot.beBetween 0.99999f And 1.000001f Exclusive

        ).Description 
        |> should.equal (format
                            Resources.TheValueShouldNoBeWithin_0_And_1_Exclusive 
                            [0.99999f;1.000001f])

    //Tolerances
    open System
    let ``it fail should.beWithin - outside desired tolerance``()=
        capture(fun()->

            (3.0 + (1.0 / 7.0)) |> should.beWithin 0.001 Of Math.PI

        ).Description
        |> should.equal (format
                            Resources.TheValueShouldBeWithin_0_of_1_
                            [0.001; Math.PI;])

    let ``it fail shouldNot.beWithin - inside tolerance``()=
        capture(fun()->

            (3.0 + (1.0 / 7.0)) |> shouldNot.beWithin 0.01 Of Math.PI

        ).Description
        |> should.equal (format
                            Resources.TheValueShouldNotBeWithin_0_of_1_
                            [0.01; Math.PI;])